package com.zhangxin.ch1;

import java.util.Scanner;

public class PreSum {
    private static final int N = 100010;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] num = new int[N];
        for (int i = 1; i <= n; i++) {
            num[i] = scanner.nextInt();
        }

        int[] preSum = new int[N];
        preSum[0] = 0;
        for (int i = 1; i <= n; i++) {
            preSum[i] = preSum[i - 1] + num[i];
        }

        while (m-- > 0) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            System.out.println(preSum[r] - preSum[l - 1]);
        }
    }
}
